package com.hsgene.user.dto.login;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.hsgene.common.util.basic.SimpleRegexUtils;
import com.hsgene.common.util.validation.FieldChecker;

import java.io.Serializable;

/**
 * 管理员登录信息
 *
 * @author wangbing
 * @version 1.0, 2018/7/11
 */
public class ManagerLoginDto implements Serializable {

    private static final long serialVersionUID = 9038192783561815875L;

    /**
     * 登录账号
     */
    private String userName;

    /**
     * 登录密码
     */
    private String password;

    /**
     * 是否需要解密密码
     */
    @JsonIgnore
    private boolean needDecrypt;

    /**
     * 登录IP
     */
    private String loginIp;

    /**
     * 当前登录用户是普通管理员还是超级管理员
     *
     * @return true：普通管理员；false：超级管理员
     */
    public boolean isNormalManagerLogin() {
        FieldChecker.checkEmpty(userName, "userName");

        return SimpleRegexUtils.isMobile(userName);
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public boolean isNeedDecrypt() {
        return needDecrypt;
    }

    public void setNeedDecrypt(boolean needDecrypt) {
        this.needDecrypt = needDecrypt;
    }

    public String getLoginIp() {
        return loginIp;
    }

    public void setLoginIp(String loginIp) {
        this.loginIp = loginIp;
    }
}
